﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Common.EventHandler;
using Domain.Common;
using Domain.Map;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace UIComponentSprite.SmallMap
{
    public class MapCloseButtonSprite : UserControlledSprite
    {
        public MapCloseButtonSprite()
        {
            this.ImgUrl = @"Images\smallMap\closeButton";
            this.ClickLeftEvent += new ClickLeftEventHandler(ChangeShowing);
            DrawPosition.Width =56;
            DrawPosition.Height = 32;
        }
        public override void Draw(GameTime gameTime)
        {
            if (!Showing)
                return;
            SpriteBatch.Draw(this.Image, DrawPosition,Color.White);
        }

        public override void Update(GameTime gameTime)
        {
            if (!Showing)
                return;
            DrawPosition.X = GameScreen.ViewportSize.X - (int)(Map.MapDimensions.X * SmallMapSprite.MapSizeMultiple) - DrawPosition.Width;//使图片刚好绘制在小地图左侧，减去小地图宽度和图片本身宽度
            DrawPosition.Y = GameScreen.ViewportSize.Y - DrawPosition.Height;
            LoadPic();
           ClickLeftEventListener(null);
        }
    }
}
